﻿@{
    Layout = "../Shared/_MobileLayout.cshtml";
}
@using Kevin.Shop.Business.Service.Entity.Helper;
@model List<RiderShop.Mobile.ServiceEntity.MyAccount.UserShipingAddressExtend>
@section header
{
    <style>
        .myAccountActive {
            color: #ff6c1f;
        }

        .tb-cell {
            display: table-cell;
            vertical-align: middle;
            font-weight: normal;
        }

        .addLine {
            width: 100%;
        }

        footer {
            display: none;
        }
    </style>

}
@section title
{
    收货地址
}
@section pagetitle
{
    收货地址
}
<div class="userCenterHeader">
    <span class="iconWrapper">
        <img src="~/Themes/RongJi/Style/base/imgs/icon_zhi.png">
    </span>
    <h3>收货地址</h3>
    <br class="clearfix">
</div>
<div class="box">
    <a href="~/MyAccount/ShippingAddressCreate?action=@Request.QueryString["action"]"><input type="button" class="btn btn-block" value="新增收货地址"></a>
    @foreach (var item in Model)
    {
        //using ((Html.BeginForm("ShippingAddressDelete", "MyAccount")))
        //{
        <input type="hidden" name="hidUserId" value="@WebClientContext.Current.UserId">
        <input type="hidden" name="hidShippingId" value="@item.ShippingId">
        <div class="well address-box mt10">
            <div class="tb-cell" style="width:100%">
                <label class="addLine" sid="@item.ShippingId">
                    @if (!string.IsNullOrEmpty(@Request.QueryString["action"]))
                    {
                        <div class="tb-cell" style="padding-right:10px;">
                            <span>
                                <input type="radio" class="radio" name="my_address" value="@item.ShippingId" @(item.IsDefault.HasValue && item.IsDefault.Value ? "checked" : "")>
                            </span>
                        </div>
                    }
                    <div class="tb-cell">
                        <p class="font-xl">
                            @item.ShipTo&nbsp;@item.CellPhone&nbsp;
                        </p>
                        <p class="font-m">
                            @item.RegionAddress
                        </p>
                        <p class="font-m">
                            @Html.Raw(@item.Address)
                        </p>
                    </div>
                </label>
            </div>
            <div class="tb-cell">
                <div style="display:block;width:80px;">
                    <a href="javascript:void(0)" onclick="deleteShippingAddress(@WebClientContext.Current.UserId,@item.ShippingId)">
                        <span class="glyphicon glyphicon-remove f25 fr p0_10"></span>
                    </a>
                    <a href="ShippingAddressEdit?userId=@WebClientContext.Current.UserId&shippingId=@item.ShippingId&number=1&action=@Request.QueryString["action"]">
                        <span class="glyphicon glyphicon-pencil f25 fr"></span>
                    </a>
                </div>
            </div>
        </div>
        @*}*@
    }

</div>
@section footer
{

    @if (!string.IsNullOrEmpty(@Request.QueryString["action"]))
    {
        <script type="text/javascript">
            $(function () {
                var oneClick = false;
                $(".addLine").click(function () {
                    if (!oneClick) {
                        oneClick = true;
                        var sid = $(this).attr('sid');
                        window.location.href = "/MyAccount/SetDefaultShippingAddress?shippingId=" + sid + "&action=@Request.QueryString["action"]";
                    }
                });

            });
        </script>
    }
    <script type="text/javascript">
        function deleteShippingAddress(hidUserId, hidShippingId) {

            KevinShop.MessageBox.Confirm("", "您确定删除吗？", function (isConfirm) {
                if (isConfirm) {
                    var data = {
                        hidUserId: hidUserId,
                        hidShippingId: hidShippingId
                    };
                    $.post("ShippingAddressDelete", data, function () {
                        window.location.reload();
                    });
                }
            });

        }

        //让toolbar选中
        var $homeImg = $("#homeImg");
        var $categoryImg = $("#categoryImg");
        var $myaccountImg = $("#myaccountImg");
        var $searchImg = $("#searchImg");

        $homeImg.attr("src", "/Themes/RongJi/Style/base/imgs/f10.png");
        $categoryImg.attr("src", "/Themes/RongJi/Style/base/imgs/f2.png");
        $myaccountImg.attr("src", "/Themes/RongJi/Style/base/imgs/f3_c.png");
        $searchImg.attr("src", "/Themes/RongJi/Style/base/imgs/f4.png");
    </script>
}